package com._public._utils._mailer 
{
	/**
	 * 支持HTML内容发送
	 * @author WZH(shch8.com)
	 */
	public class MailerHtml extends Mailer
	{
		
		public function MailerHtml() 
		{
			super()
		}
		override protected function createSendMailSteps(mail:Mail):Array 
		{
			var steps:Array = [];
			
			steps.push("HELO wzh");
			steps.push("AUTH login");
			
			steps.push(Base64.encode(userName));
			
			steps.push(Base64.encode(password));
  			
  			steps.push("MAIL FROM:<" + mail.from + ">");
  			steps.push("RCPT TO:<" + mail.tu + ">");
  			
  			if (mail.cc) {
  				var cc:Array = mail.cc;
  				
  				for(var j:uint = 0; j < cc.length; j++) {
		  			steps.push("RCPT TO:<" + cc[j] + ">");
  				}
  			}
  			
  			steps.push("DATA");
  			
			var mailData:Array = [];
			if (!mail.fromName) {
	  			mailData.push("From:" + mail.from);
			} else {
	  			mailData.push("From:" + mail.fromName);
			}
			
			if (!mail.toName) {
	  			mailData.push("To:" + mail.tu);
			} else {
	  			mailData.push("To:" + mail.toName);
			}
			
  			if (mail.subject) {
  				mailData.push("Subject:" + mail.subject);
  			}  			
  			if (mail.cc) {
  				mailData.push("CC:" + mail.cc);
  			}
  			
  			if (mail.sender) {
  				mailData.push("Sender:" + mail.sender);
  			}

			mailData.push("Content-Type: text/html; charset=GB2312; format=flowed");
			mailData.push(mail.body);
			mailData.push(".");  			
  			steps.push(mailData);
  			steps.push("QUIT");
  			
  			return steps;
		}
	}

}